package com.lee.interview.sort;

public class Test {
	public static void main(String[] args) {
		int[] a = {2,4,6,8,10,12,14};
		int[] b = {3,6,9,12,15,18};
		
		int[] c = sort(a, b);
		for (int i = 0; i < c.length; i++) {
			System.out.print(c[i]+"	");
		}
	}
	
	
	public static int[] sort(int[] a,int[] b) {
		int lengthA = a.length;
		int lengthB = b.length;
		int[] c = new int[lengthA+lengthB];
		
		int i,j,k;
		i = j = k =0;
		while (i<lengthA && j< lengthB) {
			if (a[i] < b[j]) {
				c[k++] = a[i++];
			} else {
				c[k++] = b[j++];
			}
		}
		while (i<lengthA) {
			c[k++] = a[i++];
		}
		while (j<lengthB) {
			c[k++] = b[j++];
		}
		return c ;
	}
}
